package com.mobile.ado.contacts;

import java.util.ArrayList;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

public class Contact implements Parcelable {

	private String id;
	private String name;
	private ArrayList<PhoneNumber> phones;
	private Bitmap photo;

	public Contact(String id, String name, ArrayList<PhoneNumber> phones,
			Bitmap photo) {
		super();
		this.id = id;
		this.name = name;
		this.phones = phones;
		this.photo = photo;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<PhoneNumber> getPhones() {
		return phones;
	}

	public void setPhones(ArrayList<PhoneNumber> phones) {
		this.phones = phones;
	}

	public Bitmap getPhoto() {
		return photo;
	}

	public void setImagePath(Bitmap photo) {
		this.photo = photo;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("id=" + id);
		builder.append("\n");
		builder.append("name=" + name);
		builder.append("\n");
		for (int i = 0; i < phones.size(); i++) {
			builder.append("phone=" + phones.get(i).toString());
			builder.append("\n");
		}

		return builder.toString();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel paramParcel, int paramInt) {
		paramParcel.writeString(id);
		paramParcel.writeString(name);
		paramParcel.writeList(phones);
		paramParcel.writeValue(photo);

	}

	public static final Parcelable.Creator<Contact> CREATOR = new Parcelable.Creator<Contact>() {
		public Contact createFromParcel(Parcel in) {
			return new Contact(in);
		}

		public Contact[] newArray(int size) {
			return new Contact[size];
		}
	};

	private Contact(Parcel in) {
		ClassLoader loader = this.getClass().getClassLoader();

		id = in.readString();
		name = in.readString();
		phones = in.readArrayList(loader);
		photo = (Bitmap) in.readValue(loader);
	}

}